<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>点击</button>
    <script>
        // 查询参:querystring
        /* 
        https://huodong.taobao.com/wow/a/act/tao/dailyact/5146/wupr?spm=a21bo.jianhua.201867-main.15.5af911d9JJS3KS&wh_pid=dailyAct-265555&v=2483e735cab1dcee499ab6218cd24e1c&wh_random_str=1
        */ 

        let obj = {
            myname : 'zhangsan',
            age : 20,
            height:'178cm'
        }
        // 把对象转成 固定格式的字符串
        // ?myname=zhangsan&age=20
        function o2s(obj){
            let keys = Object.keys(obj);
            let values = Object.values(obj);
            var arr = keys.map(function(key,index){
                console.log(key,index);
                return `${key}=${values[index]}`;
            })
            console.log(arr);
            return arr.join("&");
        }



        document.querySelector('button').onclick = function(){
            // 跳转的同时 携带obj的参数
            window.location.href = `b.html?${o2s(obj)}`;
        }












    </script>
</body>
</html>